@extends('admin.layouts.app')
@section('content')
    <div class="admin-content">

        <div class="am-cf am-padding">
            <div class="am-fl am-cf"><strong class="am-text-primary am-text-lg">自定义菜单</strong> /
                <small>Customer Menus</small>
            </div>
        </div>
        <br/>
        @include('admin.layouts._flash')

        <div class="am-g">
            <div class="am-u-sm-12 am-u-md-6">
                <div class="am-btn-toolbar">
                    <div class="am-btn-group am-btn-group-xs">
                        <a href="/shop/wechat/destroy" class="am-btn am-btn-secondary" id="destroy_checked" data-method="delete" data-token="{{csrf_token()}}" data-confirm="确认删除菜单吗?此操作不可恢复!">
                            <span class="am-icon-trash-o"></span> 删除菜单
                        </a>
                    </div>
                </div>
            </div>

            <div class="am-u-sm-12 am-u-md-12">

                <div class="am-tab-panel">

                    <form class="am-form " action="/shop/wechat/update" method="post">

                        {!! csrf_field() !!}
                        {!! method_field('put') !!}

                        <div class="am-tabs" data-am-tabs="" style="margin:1.6rem 0;">
                            <ul class="am-tabs-nav am-nav am-nav-tabs">
                                <li class="am-active"><a href="#tab0">菜单一</a></li>
                                <li><a href="#tab1">菜单二</a></li>
                                <li><a href="#tab2">菜单三</a></li>
                            </ul>

                            <div class="am-tabs-bd" style="touch-action: pan-y; -webkit-user-select: none; -webkit-user-drag: none; -webkit-tap-highlight-color: rgba(0, 0, 0, 0);">
                                @for($i=0;$i<3;$i++)
                                    <?php
                                    $button = isset($buttons["$i"]) ? $buttons["$i"] : "";
                                        var_dump($button);
                                    ?>
                                <div class="am-tab-panel am-fade   @if($i==0) am-in am-active  @endif  " id="tab{{$i}}">
                                    <table class="am-table am-table-hover">
                                        <thead>
                                        <tr>
                                            <th>级别</th>
                                            <th>类型</th>
                                            <th>名称</th>
                                            <th>值</th>
                                        </tr>
                                        </thead>
                                        <tbody>
                                        <tr>
                                            <td>一级菜单：</td>
                                            <td>
                                                <select class="form-control am-form-field am-radius type" name="buttons[{{$i}}][type]">
                                                    <option value="click" @if(isset($button["type"]) and $button["type"] == 'click') selected @endif>
                                                        click
                                                    </option>

                                                    <option value="view"  @if(isset($button["type"]) and $button["type"] == 'view') selected @endif>
                                                        view
                                                    </option>
                                                </select>
                                            </td>
                                            <td>
                                                <input type="text" name="buttons[{{$i}}][name]" value="{{$button['name'] or ''}}" class="am-form-field am-radius">
                                            </td>
                                            <td>
                                                <input type="text" name="buttons[{{$i}}][value]"
                                                       @if (isset($button["key"]))
                                                       value="{{$button["key"]}}"
                                                       @elseif (isset($button["url"]))
                                                       value="{{$button["url"]}}"
                                                       @else
                                                       value=""
                                                       @endif
                                                       class="am-form-field am-radius">
                                            </td>
                                        </tr>

                                    @for($j=0;$j<5;$j++)

                                        <tr>
                                            <td>二级菜单：{{$j+1}}</td>

                                            <td>
                                                <select class="form-control am-form-field am-radius type" name="buttons[{{$i}}][sub_button][{{$j}}][type]">
                                                    <option value="click" @if(isset($button['sub_button']["$j"]["type"]) and $button['sub_button']["$j"]["type"]== 'click') selected @endif>
                                                        click
                                                    </option>

                                                    <option value="view" @if(isset($button['sub_button']["$j"]["type"]) and $button['sub_button']["$j"]["type"] == 'view') selected @endif>
                                                        view
                                                    </option>
                                                </select>
                                            </td>
                                            <td>
                                                <input type="text" name="buttons[{{$i}}][sub_button][{{$j}}][name]"
                                                       value="{{$button['sub_button']["$j"]['name'] or ''}}"
                                                       class="am-form-field am-radius">
                                            </td>
                                            <td>
                                                <input type="text" name="buttons[{{$i}}][sub_button][{{$j}}][value]"
                                                       @if (isset($button['sub_button']["$j"]["key"]))
                                                       value="{{$button['sub_button']["$j"]["key"]}}"
                                                       @elseif (isset($button['sub_button']["$j"]["url"]))
                                                       value="{{$button['sub_button']["$j"]["url"]}}"
                                                       @else
                                                       value=""
                                                       @endif

                                                       class="am-form-field am-radius">
                                            </td>
                                        </tr>

                                        @endfor
                                        </tbody>
                                    </table>
                                </div>
                                @endfor
                            </div>
                        </div>

                        <div class="am-margin">
                            <button type="submit" class="am-btn am-btn-primary">保存修改</button>
                        </div>

                    </form>
                </div>
            </div>
        </div>
    </div>
    @endsection